#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMenuBar>
#include <QStatusBar>
#include <QLabel>
#include <QString>
#include <QLayout>
#include "ControlPanel.h"
#include "FrameShower.h"
#include "Mcs.h"
#include <memory>
#include <QImage>
#include <QPointer>
#include <QToolBar>
#include "ImportDialog.h"

class MainWindow : public QMainWindow
{
Q_OBJECT
public:
    static MainWindow* Instance();

private:
    static MainWindow* instance;

private:
    MainWindow();
    ~MainWindow() override;

private:
    QLabel* statusText = nullptr;
    QWidget* mainWidget = nullptr;
    QHBoxLayout* mainLayout = nullptr;

    ControlPanel* controlPanel = nullptr;
    FrameShower* frameShower = nullptr;

    std::unique_ptr<QMenu> fileMenu = nullptr;
    std::unique_ptr<QAction> fileOpenAction = nullptr;
    std::unique_ptr<QAction> fileSaveAction = nullptr;
	std::unique_ptr<QAction> fileImportAction = nullptr;
    std::unique_ptr<QAction> fileQuitAction = nullptr;

    QToolBar* toolBar = nullptr;

public:
    std::unique_ptr<QImage> GetMcsImage(int frameId = 0);
    std::shared_ptr<Mcs> GetMcs();

public slots:
    void SetStatusText(const QString& text);

protected:
    void resizeEvent(QResizeEvent *event) override;

signals:
    void McsUpdate();

private slots:
    void OnFileOpenActionCalled();
    void OnFileSaveActionCalled();
	void OnFileImportActionCalled();
    void OnFileQuitActionCalled();

public slots:
    void UpdateImage(const QColor& c, int index);

private:
    std::shared_ptr<Mcs> mcs = nullptr;
    QColor backgroundColor = QColor(0, 0, 255);
};




#endif //MAINWINDOW_H
